package com.evan.aiu.service;

import com.evan.aiu.dao.CommentDAO;
import com.evan.aiu.entity.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {
    @Autowired
    CommentDAO commentDAO;

    public Comment findById(int id) {
        return commentDAO.findById(id);
    }

    public List<Comment> findByAid(int aid) {
        return commentDAO.findAllByAnswerId(aid);
    }

    public void addOrUpdate(Comment comment) {
        commentDAO.save(comment);
    }

    public void delete(int id) {
        commentDAO.deleteById(id);
    }
}
